<!--
 * @Author: your name
 * @Date: 2020-04-24 11:02:39
 * @LastEditTime: 2020-06-09 15:15:35
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \v-nw-h5\src\pages\user\Setting.vue
--> 
<template>
    <div class="setting">
        <!--这里问下产品不要就删掉-->
        <div class="setting-btn-warp displayFlex flexCenter">
            <button class="exit-login-btn password-btn" @click="openHKHWConfirm('更多操作请下载【好看好玩】')">修改密码</button>
        </div>
        <div class="setting-btn-warp displayFlex flexCenter">
            <button class="exit-login-btn" @click="exitLogin">退出登录</button>
        </div>
    </div>
</template>

<script>
export default {
    name: "Setting",
    methods: {
        exitLogin () {
            let url = `${this.NW_API_API_LOCALE_VERSION}/user/account/${this.userId}/logout?terminalType=CustomerH5`;
            this.xurl.post(url).then((data) => {
                /*跟新用户信息，然后跳转*/
                if (data.success) {
                    // let nextPage = window.localStorage.getItem(this.NEXTPAGE);
                    this.$store.dispatch('loginOut');
                    this.$root.$emit("toast", { msg: "退出登录成功" });
                    localStorage.clear('share') // 退出需清除微信记录的缓存
                    setTimeout(() => {
                        window.location.href = '/home';
                    }, 1500);
                } else if (data.errMsg) {
                    this.$root.$emit("toast", { msg: data.errMsg });
                } else {
                    this.$root.$emit("toast", { msg: "退出登录失败" });
                }

            });
        },
    }
}
</script>

<style scoped>
.setting {
    min-height: 6.67rem;
    min-height: 100vh;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    padding: 0.2rem 0;
}
.exit-login-btn {
    width: 84%;
    height: 44px;
    line-height: 44px;
    text-align: center;
    border-radius: 25px;
    background-color: #8ba9e8;
    color: #fff;
    font-size: 15px;
    margin-top: 40px;
}
.password-btn {
    background-color: #fe4c4c;
}
</style>